/*
 * Copyright 2010 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package it.davial.mgwt.client;

import it.davial.mgwt.client.activities.about.AboutView;
import it.davial.mgwt.client.activities.about.AboutViewImpl;
import it.davial.mgwt.client.activities.menu.MenuView;
import it.davial.mgwt.client.activities.menu.MenuViewImpl;
import it.davial.mgwt.client.activities.patient.PatientView;
import it.davial.mgwt.client.activities.patient.PatientViewImpl;
import it.davial.mgwt.client.activities.patient.detail.PatientDetailView;
import it.davial.mgwt.client.activities.patient.detail.PatientDetailViewImpl;
import it.davial.mgwt.client.activities.picture.PictureView;
import it.davial.mgwt.client.activities.picture.PictureViewImpl;
import it.davial.mgwt.client.activities.visit.VisitView;
import it.davial.mgwt.client.activities.visit.VisitViewImpl;
import it.davial.mgwt.client.test.TestView;
import it.davial.mgwt.client.test.TestViewImpl;

import com.google.gwt.place.shared.PlaceController;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;

/**
 * @author Daniel Kurka
 * 
 */
public class ClientFactoryImpl implements ClientFactory {

	private EventBus eventBus;
	private PlaceController placeController;
	private PictureView picture;
	private MenuView menu;
	private VisitView visit;
	private PatientView patient;
	private PatientDetailView patientDetail;
	private AboutView about;
	private TestView vince;
	
	public ClientFactoryImpl() {
		eventBus = new SimpleEventBus();

		placeController = new PlaceController(eventBus);
	}

	@Override
	public EventBus getEventBus() {
		return eventBus;
	}

	@Override
	public PlaceController getPlaceController() {
		return placeController;
	}

	@Override
	public PictureView getPictureView() {
		if ( picture==null){
			picture = new PictureViewImpl();
		}
		return picture;
	}

	@Override
	public MenuView getMenuView() {
		if ( menu==null){
			menu = new MenuViewImpl();
		}
		return menu;
	}

	@Override
	public VisitView getVisitView() {
		if ( visit == null )
			visit = new VisitViewImpl();
		return visit;
	}

	@Override
	public PatientView getPatientView() {
		if (patient == null)
			patient = new PatientViewImpl();
		return patient;
	}

	@Override
	public PatientDetailView getPatientDetailView() {
		if (patientDetail == null)
			patientDetail = new PatientDetailViewImpl();
		return patientDetail;
	}

	@Override
	public AboutView getAboutView() {
		if (about == null)
			about = new AboutViewImpl();
		return about;
	}

	@Override
	public TestView getVinceView() {
		if (vince == null)
			vince = new TestViewImpl();
		return vince;
	}

}
